home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 263_02 / readfile.c < prev    next >
Text File  |  1990-02-13  |  1KB  |  36 lines

  1. #include <stdio.h>
  2. #include <c_wndw.h>
  3.  
  4. /*
  5. *    Copyright 1989, Marietta Systems, Inc.
  6. *    All rights reserved
  7. */
  8.  
  9. /*
  10. *    This program reads the file "TEST.DAT" by record number.
  11. *   If the record exists, it is displayed.
  12. *    The program WRITFILE.C can be used to create the file.
  13. */
  14.  
  15. void main ()
  16. {
  17.      long recno = 1L;
  18.      int fh, ret = 1, in;
  19.      clr_scrn ("Read the file");
  20.      fh = fileopen ("MARIETTA\\TEST.DAT", binary, readonly);
  21.      if (!fh) goodbye (err_wndw (" TEST.DAT file not found ", 0, 0));
  22.      if (fh < 0) goodbye (10); /* error end to the program */
  23.      fileinit (fh, 0, 61, 0L); /* set record length at 61 bytes */
  24.      for (;;)
  25.      {
  26.           display ("Which record number to read? ", 1, 1, high);
  27.           ret = acptlong (&recno, code, alt_high, 3);
  28.           if (ret == QUIT) break;
  29.           in = fileread (fh, relative, &recno); /* read the record */
  30.           if (in == 1) display (FN[fh].record, 2, 5, reverse);
  31.           else err_wndw (" Record not found ", 0, 9);     
  32.      }
  33.      fileclos (fh);     
  34.      goodbye (0);
  35. }
  36.